package snippet;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.*;

public class first {

	/*
	 * Complete the simpleArraySum function below.
	 */
	static int simpleArraySum(int[] ar) {
		int num = 0;
		for(int i=0;i<ar.length;i++) {
			num += ar[i];
		}
		System.out.println(num);
		return num;
	}

	private static final Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) throws IOException {
		BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter("first.txt"));

		//将用户输入的内容去空格并转换为Integer类型
		System.out.println("请输入数组长度!");
		int arCount = Integer.parseInt(scanner.nextLine().trim());

		//设置为数组的长度
		int[] ar = new int[arCount];
		//将输入的内容按空格拆分
		System.out.println("请分别输入"+arCount+"个数字,使用空格分隔!");
		String[] arItems = scanner.nextLine().split(" ");


		for (int arItr = 0; arItr < arCount; arItr++) {
			int arItem = Integer.parseInt(arItems[arItr].trim());
			ar[arItr] = arItem;
		}

		int result = simpleArraySum(ar);

		bufferedWriter.write(String.valueOf(result));
		bufferedWriter.newLine();

		bufferedWriter.close();
	}
}